const { ipcMain } = require('electron')
const fs = require('fs')
const path = require('path')
const { readdir } = require('fs/promises')

// ipcMain.handle('on-getfiles-event', (e,arg) => {
//     // 同步写法
//     const files = fs.readdirSync(path.resolve(__dirname,"../public/uploads/"))
//     return files
// })


ipcMain.handle('on-getfiles-event', async (e,arg) => {
    // 异步写法
    const files = await readdir(path.resolve(__dirname,"../public/uploads/"))
    return files
})